{% extends 'form_div_layout.html.twig' %}

{% block textarea_widget %}
{% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
{{ parent() }}
{% endblock textarea_widget %}

{% block form_widget_simple %}
{% filter spaceless %}
    {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %}
    {% set type = type|default('text') %}

    {{ parent() }}
{% endfilter %}
{% endblock form_widget_simple %}

{% block form_row %}
{% filter spaceless %}
    <div class="form-group{% if errors|length > 0 %} has-error{% endif %}">
        {{ form_label(form) }}

        {{ form_widget(form) }}

        {% for error in errors %}
            <span class="help-block form-error">
                {{
                    error.messagePluralization is null
                    ? error.messageTemplate|trans(error.messageParameters, 'validators')
                    : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators')
                }}
            </span>
        {% endfor %}
    </div>
{% endfilter %}
{% endblock form_row %}

{% block form_errors %}
{% filter spaceless %}
    {% if errors|length > 0 %}
        {% for error in errors %}
            <div class="alert alert-danger">{{ error.message }}</div>
        {% endfor %}
    {% endif %}
{% endfilter %}
{% endblock form_errors %}
